﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM.CSS.SAC.Conditions
{
    #region Using Statements

    using System;
    using KLF.Lib.Browser.DOM.HTML;

    #endregion

    public class IdCondition : Condition
    {
        public IdCondition(string _id)
        {
            Id = _id.StartsWith("#") ? _id.Substring(1) : _id;
        }

        public string Id { get; set; }

        public override ConditionType Type
        {
            get { return ConditionType.IdCondition; }
        }

        public override string ToString()
        {
            return String.Format("[id=\"{0}\"]", Id);
        }

        public override bool MatchElement(KLF.Lib.Browser.DOM.HTML.HTMLElement e)
        {
            return e.getAttribute(HTMLConstants.HTML_ATT_ID).Equals(Id);
        }
    }
}
